package com.kiss.rpc;

import com.kiss.rpc.channelhandler.ConsumerChannelInitializer;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.Getter;

public class NettyBootstrapInitializer {

    @Getter
    private static final Bootstrap bootstrap = new Bootstrap();
    private static final NioEventLoopGroup group = new NioEventLoopGroup(2);
    static {
        bootstrap.group(group)
                .channel(NioSocketChannel.class)
                .handler(new ConsumerChannelInitializer());
    }

    private NettyBootstrapInitializer() {
        //
    }

    public static void shutdown() throws InterruptedException {
        group.shutdownGracefully().sync();
    }
}
